﻿// Open Source: MIT License (http://www.opensource.org/licenses/mit-license.php)
// Project: YoProgramo.NET (http://code.google.com/p/yoprogramo/)
// Autor: Fabian Figueredo (info@fabianfigueredo.com.ar)
// Blog: blog.yoprogramo.net

using System.Collections.Generic;
using System.Web.Mvc;
using YoProgramo.Domain.BusinessLogic.Service;
using YoProgramo.Infrastructure.Tools.PagedList;

namespace YoProgramo.Web.Controllers {
    [HandleError]
    public class HomeController : Controller {

        public HomeController(IStoryService storyService, ITagService tagService)
        {
            _storyService = storyService;
            _tagService = tagService;
        }

        public ActionResult Index(int? page) {
            ViewData["Title"] = "Portada";
            ViewData["Tags"] = _tagService.GetAllTagsClean();
            ViewData["UrlPaging"] = Url.RouteUrl("PagginDefault", new { controller = "Home", action="Index", page = "__PAGENUM__" }); //For paging

            var stories = _storyService.GetStoriesForHome(20).ToPagedList(page ?? 0, 20);
            return View(stories);
        }

        public ActionResult Info() {
            return View();
        }

        public ActionResult About() {
            return View();
        }

        private ITagService _tagService;
        private IStoryService _storyService;
    }
}
